import { useEffect, useState } from 'react';
import { getImage } from '@/services/mail';

// 收件箱邮件列表
const useAvatarUrl = query => {
    const [loading, setLoading] = useState(false);
    const [resData, setResData] = useState([]);

    const fetchData = async () => {
        setLoading(true);
        const { data, code } = await getImage(query);
        if (code === 10000) {
            setResData(data);
        }
        setLoading(false);
    };
    useEffect(() => {
        if (query && query.length > 0) {
            fetchData();
        }
    }, [query]);
    return { loading, resData };
};

export default useAvatarUrl;
